/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * \file
 * \brief Common datatypes for form data-exchange.
 * \author Antti Maula <antti.maula@tkk.fi>
 *
 */
#ifndef _GIMBO_MACI_ALARM_DATATYPES_HPP_
#define _GIMBO_MACI_ALARM_DATATYPES_HPP_
#include <string>
#include "AlarmClient.hpp"

struct SEventsDisplayConfiguration
{
  SEventsDisplayConfiguration(void);
  bool SaveXMLFile(const std::string &aXmlFilename, const std::string &aRootKey);
  bool LoadXMLFile(const std::string &aXmlFilename, const std::string &aRootKey);
  
  bool isLimitEventsEnabled;    ///< Is events limiting enabled?
  unsigned int eventLimit;      ///< What is the event limit? 

  unsigned int enabledEvents;   ///< Bitmask of enabled events, defined by ( 1<<KEventType<...> )

  bool isQuestionPopupEnabled;  ///< Is Question popup enabled?
  bool isAckPopupEnabled;       ///< Is Acknowledgement popup enabled?
};

/**
 * Question answer type.
 */
enum EQuestionAnswer {
  KAnswerNone,          ///< Not defined.
  KAnswerYes,           ///< Answer is YES
  KAnswerNo,            ///< Answer is NO
  KAnswerIgnore         ///< Answer is IGNORE. (timeout / close / cancel)
};


/** Structure for grouping information together.
 *
 */
struct SAlarmInfo
{
  public:
  SAlarmInfo(void)
    : alarm(),
      alarmClientPtr(NULL),
      listindex(-1),
      isProtected(false),
      answer(KAnswerNone),
      entryTimestamp(true)
  {}
  SAlarmInfo(const MaCI::Alarm::CAlarmData &aData,
             MaCI::Alarm::CAlarmClient *aClient) 
    : alarm(aData),
      alarmClientPtr(aClient),
      listindex(-1),
      isProtected(false),
      answer(KAnswerNone),
      entryTimestamp(true)
  {}

  SAlarmInfo(const SAlarmInfo &aSrc) 
    : alarm(),
      alarmClientPtr(NULL),
      listindex(-1),
      isProtected(false),
      answer(KAnswerNone),
      entryTimestamp(true)
  {
    *this = aSrc;
  }
  
  SAlarmInfo &operator=(const SAlarmInfo &aSrc) {
    // Note; Doing direct member copy, as the pointer stored here is
    // not owned here, hence it will never be destroyed by this class.
    alarm = aSrc.alarm;
    alarmClientPtr = aSrc.alarmClientPtr;
    listindex = aSrc.listindex;
    return *this;
  }

  inline void SetAlarmData(const MaCI::Alarm::CAlarmData &aData) {
    alarm = aData;
  }
  inline const MaCI::Alarm::CAlarmData &GetAlarmData(void) const {
    return alarm;
  }
  inline void SetAlarmClientPtr(MaCI::Alarm::CAlarmClient *aClientPtr) {
    alarmClientPtr = aClientPtr;
  }
  inline MaCI::Alarm::CAlarmClient *GetAlarmClientPtr(void) const {
    return alarmClientPtr;
  }
  inline int GetListIndex(void) const {
    return listindex;
  }
  inline void SetListIndex(const int aIndex) {
    listindex = aIndex;
  }
  inline void SetProtected(const bool aIsProtected) {
    isProtected = aIsProtected;
  }
  inline bool IsProtected(void) const {
    return isProtected;
  }
  inline void SetAnswer(EQuestionAnswer aAnswer) {
    answer = aAnswer;
  }
  inline EQuestionAnswer GetAnswer(void) const {
    return answer;
  }
  inline void SetEntryTimestamp(const gim::time &aTime) {
    entryTimestamp = aTime;
  }
  inline const gim::time &GetEntryTimestamp(void) const {
    return entryTimestamp;
  }

public:
  MaCI::Alarm::CAlarmData alarm;             ///< AlarmData object.
  MaCI::Alarm::CAlarmClient *alarmClientPtr; ///< Pointer to client where this object came from.
  int listindex;                             ///< Index in list, -1 if not in list.
  bool isProtected;                          ///< Marked as protected entry. Will not be cleaned up.
  EQuestionAnswer answer;                    ///< Answer state
  gim::time entryTimestamp;                  ///< Entry timeout
};




#endif
